<%@page import="cn.com.common.base.bean.PageBean"%>
<%@page import="cn.com.common.ui.PageTagHelper"%>
<%@page import="cn.com.common.Constants"%>
<%@page import="cn.com.common.base.bean.BackstageResult"%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>测试例子</title>
<%@include file="/WEB-INF/page/commons/import.jsp" %> 

</head>

<script type="text/javascript">
	function toEdit(id,targetBt){
		showCustomDiv(true, "apdiv", 1, true);
		$(targetBt).attr("disabled",true);
		$("#oprId").val(id);
		var form = $("#listForm");
		form.attr("action","demoXmlUser_edit");
		form.submit();
	}
	function toDelete(id,targetBt){
		if (!confirm("确定要删除吗？")){
			return ;
		}
		showCustomDiv(true, "apdiv", 1, true);
		$(targetBt).attr("disabled",true);
		$("#oprId").val(id);
		var form = $("#listForm");
		form.attr("action","demoXmlUser_delete");
		form.submit();
	}
	function search(){
		$("#queryPageNow").val(1);
		$("#oprId").val("");
		refresh();
	}
	function refresh(){
		showCustomDiv(true, "apdiv", 1, true);
		var form = $("#listForm");
		form.attr("action","demoXmlUser_toIndex");
		form.submit();
	}
	function goPage(pn,targetBt){
		$(targetBt).attr("disabled",true);
		$("#queryPageNow").val(pn);
		refresh();
	}
</script>
<body>
	<h1>	</h1>
		<div>
			<div>
				<s:form action="demoXmlUser_toIndex" method="post" id="listForm" namespace="/demo/xml">
					名称:<s:textfield name="queryBean.userName" />
					生日<s:textfield name="queryBean._birthday_condtion_GT" />
					-<s:textfield name="queryBean._birthday_condtion_LT" />
					<input type="button" value="查询" onclick="search()"> 
					<input type="button" value="添加" onclick="toEdit(-1)"> 
					<s:hidden name="oprBean.id" value="-1" id="oprId"></s:hidden>
					<s:hidden name="queryBean._pageNow" id="queryPageNow"></s:hidden>
					<s:token />
				</s:form>
			</div>
			<table>
				<tr>
					<th>ID</th>
					<th>用户名</th>
					<th>真实姓</th>
					<th>性别</th>
					<th>生日</th>
					<th>操作</th>
				</tr>
				<s:if test="#pageItem!=null && #pageItem.rows!=null && #pageItem.rows.size()>0">
					<s:iterator var="tmpBean" value="#pageItem.rows" status="status">
						<tr>
							<td><s:property value="#tmpBean.id" /> &nbsp;</td>
							<td><s:property value="#tmpBean.userName" /> &nbsp;</td>
							<td><s:property value="#tmpBean.realName" /> &nbsp;</td>
							<td>
								<s:if test="#tmpBean.sex==1">
									男
								</s:if><s:else>女</s:else>
							&nbsp;</td>
							<td><s:property value="#tmpBean.birthday"/>&nbsp;</td>
							<td>
								<input type="button" value="修改" onclick="toEdit(<s:property value="#tmpBean.id" />,this)" /> 
								<input type="button" value="删除" onclick="toDelete(<s:property value="#tmpBean.id" />,this)">
							</td>
						</tr>
					</s:iterator>
				</s:if>
			</table>

			<div>
			
				<%
					PageBean pageBean = (PageBean)request.getAttribute("pageItem");
					if(pageBean!=null){
						String pageTag = PageTagHelper.getPageTag(pageBean.getPageNow(), pageBean.getPageCount(), pageBean.getTotal(),0) ;
						out.print(pageTag);	
					}
				%>
			</div>
		</div>

	
	<div id="apdiv"
				style="z-index: 5; position: absolute; display: none; background: #FFFFFF; border: 1px solid #000000; height: 200px; width: 300px; text-align: center">
		<br /><br /><br /><br /><br /><br /><br />
		<div>正在执行，请稍等...</div>
	</div>
	
<%
BackstageResult bResult = (BackstageResult)request.getAttribute(Constants.SYSTEM_ACTION_RESUT_MSG);
if(bResult!=null){
	if(bResult.isStatus() && Integer.valueOf(1).equals(bResult.getMsg())){
		%>
		<script type="text/javascript">
			alert("操作成功");
			refresh();
		</script>
		<%
	}else{
		%>
		<script type="text/javascript">
			alert("操作失败,<%=bResult.getMsg()%>");
		</script>
		<%
	}
}
%>	
	
</body>
</html>